package com.kzw.oa.model.system;

import java.io.Serializable;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;

public class UserOrg implements Serializable {
	/**
	 * 主要
	 */
	public static final Short PRIMARY = 1;
	/**
	 * 非主要
	 */
	public static final Short NOT_PRIMARY = 0;

	/**
	 * 主负责, 分管
	 */
	public static final Short CHARGE = 1;
	/**
	 * 非负责
	 */
	public static final Short NOT_CHARGE = 0;

	protected Long userOrgId;
	protected Short isPrimary;
	protected Short isCharge;
	protected AppUser appUser;
	protected Department dept;

	// 加上orgId为了方便Json格式化处理
	public Long orgId;

	/**
	 * Default Empty Constructor for class UserOrg
	 */
	public UserOrg() {
		super();
	}

	/**
	 * Default Key Fields Constructor for class UserOrg
	 */
	public UserOrg(Long in_userOrgId) {
		this.setUserOrgId(in_userOrgId);
	}

	public AppUser getAppUser() {
		return appUser;
	}

	public void setAppUser(AppUser in_appUser) {
		this.appUser = in_appUser;
	}

	public Long getUserOrgId() {
		return this.userOrgId;
	}

	public void setUserOrgId(Long aValue) {
		this.userOrgId = aValue;
	}

	public Long getUserid() {
		return this.getAppUser() == null ? null : this.getAppUser().getUserId();
	}

	/**
	 * Set the userid
	 */
	public void setUserid(Long aValue) {
		if (aValue == null) {
			appUser = null;
		} else if (appUser == null) {
			appUser = new AppUser(aValue);
		} else {
			appUser.setUserId(aValue);
		}
	}


	public Short getIsPrimary() {
		return this.isPrimary;
	}

	public void setIsPrimary(Short aValue) {
		this.isPrimary = aValue;
	}

	public Short getIsCharge() {
		return this.isCharge;
	}

	/**
	 * Set the isCharge
	 */
	public void setIsCharge(Short aValue) {
		this.isCharge = aValue;
	}

	/**
	 * @see java.lang.Object#equals(Object)
	 */
	public boolean equals(Object object) {
		if (!(object instanceof UserOrg)) {
			return false;
		}
		UserOrg rhs = (UserOrg) object;
		return new EqualsBuilder().append(this.userOrgId, rhs.userOrgId)
				.append(this.isPrimary, rhs.isPrimary)
				.append(this.isCharge, rhs.isCharge).isEquals();
	}

	/**
	 * @see java.lang.Object#hashCode()
	 */
	public int hashCode() {
		return new HashCodeBuilder(-82280557, -700257973)
				.append(this.userOrgId).append(this.isPrimary)
				.append(this.isCharge).toHashCode();
	}

	/**
	 * @see java.lang.Object#toString()
	 */
	public String toString() {
		return new ToStringBuilder(this).append("userOrgId", this.userOrgId)
				.append("isPrimary", this.isPrimary)
				.append("isCharge", this.isCharge).toString();
	}

	public Department getDept() {
		return dept;
	}

	public void setDept(Department dept) {
		this.dept = dept;
	}

	public Long getOrgId() {
		return orgId;
	}

	public void setOrgId(Long orgId) {
		this.orgId = orgId;
	}
}
